package com.teamwork.common.entity.common;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.teamwork.common.util.RegexUtil;
import lombok.Data;


import javax.validation.constraints.Email;
import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;

@Data
@TableName("tb_user")
public class User {

    Long id;

    @Pattern(regexp = RegexUtil.REGEX_USERNAME, message = "用户名必须是字母，数字的组合，6-16位")
    String username;

    @Pattern(regexp = RegexUtil.REGEX_PASSWORD,message = "密码必须是字母，数字的组合，6-16位")
    String password;

//    @Pattern(regexp = RegexUtil.REGEX_PHONE,message = "以1开头，第二位为345678任意一个，后九位为0到9的任意数")
    String phone;

//    @Pattern(regexp = RegexUtil.REGEX_EMAIL,message = "邮箱格式不正确")
    @Email(message = "邮箱格式不正确")
    String email;

    Integer status;

    Integer role;

    String nickname;

    @TableField(value = "createtime",fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    LocalDateTime createtime;

    @TableField(value = "updatetime",fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    LocalDateTime updatetime;
}
